<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>精选文章</title>
    <!-- 必须的 meta 标签 -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap 的 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
          integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
    <!-- 1. 导入CSS的全局样式 -->
    <%--    <link href="css/bootstrap.min.css" rel="stylesheet">--%>
    <style>
        .content {
            margin-left: 20px;
            margin-top: 10px;
        }
    </style>

</head>
<body>

<div id="articleList" class="content">
    <h3 style="text-align: center">精选文章</h3>
    <div style="float: right; margin: 5px;">
        <a class="btn btn-primary" href="${pageContext.request.contextPath}/index.html">返回</a>

    </div>
    <form id="form_summit">
        <table border="1" class="table table-bordered table-hover" style="text-align: center;">
            <tr class="success" style="background-color: #4CB051;border-radius: 5px;">
                <th>ID</th>
                <th>作者</th>
                <th>标题</th>
                <th>类型</th>
                <th>发布时间</th>
                <th>更新时间</th>
                <th>浏览量</th>
                <th>点赞量</th>
                <th>查看内容</th>
            </tr>
            <c:forEach items="${list}" var="article" varStatus="s">
            <tr>
                <td>${s.count}</td>
                <td>${article.username}</td>
                <td>${article.title}</td>
                <td>${article.cname}</td>
                <td>${article.createTime}</td>
                <td>${article.modifyTime}</td>
                <td>${article.browserNum}</td>
                <td>${article.favour}</td>
                <td><a href="${pageContext.request.contextPath}/article/lookArticle?rid=${article.rid}">点击查看文章内容</a></td>
            </c:forEach>
            </tr>
        </table>
    </form>
</div>
<div>
    <nav>
        <ul class="pagination">

            <div>
    <span style="font-size: 25px; margin-left: 25px;">
        共<span style="color: blue;">${pb.totalCount}</span>条记录，共<span style="color: blue;">${pb.totalPage}</span>页
    </span>
            </div>

            <br>

            <li class="page-item">
                <a class="page-link"
                   href="${pageContext.request.contextPath}/article/seekGoodArticle?currentPage=${pb.currentPage - 1}&rows=10"
                   aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <ul class="pagination">
                <c:set var="previousPages" value="${pb.currentPage - 5}" />
                <c:set var="nextPages" value="${pb.currentPage + 4}" />

                <c:if test="${previousPages < 1}">
                    <c:set var="previousPages" value="1" />
                </c:if>

                <c:if test="${pb.totalPage < nextPages}">
                    <c:set var="nextPages" value="${pb.totalPage}" />
                </c:if>

                <c:forEach begin="${previousPages}" end="${nextPages}" var="i">
                    <c:if test="${pb.currentPage == i}">
                        <li class="page-item active">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/article/seekGoodArticle?currentPage=${i}&rows=10">${i}</a>
                        </li>
                    </c:if>
                    <c:if test="${pb.currentPage != i}">
                        <li class="page-item">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/article/seekGoodArticle?currentPage=${i}&rows=10">${i}</a>
                        </li>
                    </c:if>
                </c:forEach>

                <li class="page-item">
                    <a class="page-link"
                       href="${pageContext.request.contextPath}/article/seekGoodArticle?currentPage=${pb.currentPage + 1}&rows=10"
                       aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </ul>
    </nav>
</div>
</div>

</body>
</html>
